/*{
"CATEGORIES": [
"Wipe"
],
"CREDIT": "Automatically converted from https://www.github.com/gl-transitions/gl-transitions/tree/master/perlin.glsl",
"DESCRIPTION": "",
"INPUTS": [
{
"NAME": "startImage",
"TYPE": "image"
},
{
"NAME": "endImage",
"TYPE": "image"
},
{
"DEFAULT": 0,
"MAX": 1,
"MIN": 0,
"NAME": "progress",
"TYPE": "float"
},
{
"DEFAULT": 12.9898,
"MAX": 100,
"MIN": 0,
"NAME": "seed",
"TYPE": "float"
},
{
"DEFAULT": 0.01,
"MAX": 1,
"MIN": 0,
"NAME": "smoothness",
"TYPE": "float"
},
{
"DEFAULT": 4,
"MAX": 10,
"MIN": 0,
"NAME": "scale",
"TYPE": "float"
}
],
"ISFVSN": "2"
}
*/
vec4 getFromColor(vec2 inUV) {
return IMG_NORM_PIXEL(startImage, inUV);
}
vec4 getToColor(vec2 inUV) {
return IMG_NORM_PIXEL(endImage, inUV);
}
// Author: Rich Harris
// License: MIT
#ifdef GL_ES
precision mediump float;
#endif
// http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
float random(vec2 co)
{
highp float a = seed;
highp float b = 78.233;
highp float c = 43758.5453;
highp float dt= dot(co.xy ,vec2(a,b));
highp float sn= mod(dt,3.14);
return fract(sin(sn) * c);
}
// 2D Noise based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
// Four corners in 2D of a tile
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
// Smooth Interpolation
// Cubic Hermine Curve. Same as SmoothStep()
vec2 u = f*f*(3.0-2.0*f);
// u = smoothstep(0.,1.,f);
// Mix 4 coorners porcentages
return mix(a, b, u.x) +
(c - a)* u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
vec4 transition (vec2 uv) {
vec4 from = getFromColor(uv);
vec4 to = getToColor(uv);
float n = noise(uv * scale);
float p = mix(-smoothness, 1.0 + smoothness, progress);
float lower = p - smoothness;
float higher = p + smoothness;
float q = smoothstep(lower, higher, n);
return mix(
from,
to,
1.0 - q
);
}
void main() {
gl_FragColor = transition(isf_FragNormCoord.xy);
}